<?php

namespace App\Models;

//use App\Traits\RoleTrait;
use Carbon\Carbon;
use Eloquent as Model;

/**
 * Class News
 * @package App\Models
 * @version February 21, 2017, 8:13 am UTC
 */
class News extends Model
{

//    use RoleTrait;
    public $table = 'news';
    
    const CREATED_AT = 'created_at';
    const UPDATED_AT = 'updated_at';
    //新增一个add_time属性
    protected $appends = ['add_time'];
    public $fillable = [
        'title',
        'author',
        'abstract',
        'addtime',
        'visit',
        'content',
        'image',
        'origin',
        'label',
        'column_id',
        'status',
        'isaudit'
    ];

    /**
     * The attributes that should be casted to native types.
     *
     * @var array
     */
    protected $casts = [
        'id' => 'integer',
        'title' => 'string',
        'author' => 'string',
        'abstract' => 'string',
        'addtime' => 'integer',
        'visit' => 'integer',
        'content' => 'string',
        'image' => 'string',
        'origin' => 'string',
        'label' => 'string',
        'status' => 'integer',
        'isaudit' => 'integer'
    ];

    /**
     * Validation rules
     *
     * @var array
     */
    public static $rules = [
        
    ];

    /**
     * Get the created at attribute.
     *
     * @param $value
     * @return string
     */
    public function getAddTimeAttribute($value)
    {
        return date('Y-m-d H:i:s',$this->attributes['addtime']);
    }

}
